package com.lhq.utils;

import java.util.Random;

/**
 * @ClassName SaltUtils
 * @Description:类描述
 * @Author Tedu
 * @Date 2021/7/18 17:05
 * @Version V1.0
 **/
public class SaltUtils {
    public static String getSalt(int n){
        char[] chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".toCharArray();
        StringBuilder sb = new StringBuilder();
        for (int i=0; i<n;i++){
            char aChar = chars[new Random().nextInt(chars.length)];
            sb.append(aChar);
        }

        return sb.toString();
    }

    public static void main(String[] args) {
        String salt = getSalt(8);
        System.out.println(salt);
    }

}
